import React, { useImperativeHandle, useRef } from 'react'
function Test(props,ref){
  useImperativeHandle(ref,()=>{
    console.log('use')
    return handleClick
  },[])
  const handleClick = ()=>{
    console.log('test')
  }
  return (
    <>
      Test
    </>
  )
}
const TestWrapper = React.forwardRef(Test)
export default function App() {
  const inputRef = useRef()
  const inputRef1 = React.createRef()
  const TestRef = useRef()
  return (
    <div>
      <TestWrapper ref={TestRef}/>
      <input ref={inputRef} type='text'></input>
      <button onClick={
      ()=>{
        // console.log(inputRef.current.value)
        console.log(TestRef)
      }
      }>获取input</button>
       <input ref={inputRef1} type='text'></input>
      <button onClick={
      ()=>{
        console.log(inputRef1.current.value)
      }
      }>获取input</button>
    </div>
  )
}
